//
//  XMAppStore.swift
//  AnneKit-Swift
//
//  Created by 寜小陌 on 2021/3/3.
//  Copyright © 2021 宁小陌. All rights reserved.
//

import Foundation
import UIKit

public class XMAppStore: NSObject {
    
    public static let shared = XMAppStore.init()
    
    /// 去App Store评分 <AppID: app的Id>
    public func nxm_oAppStoreScore(_ AppID: String) {
        let urlStr = "itms-apps://itunes.apple.com/app/id\(AppID)?action=write-review"
//        UIApplication.shared.openURL(URL.init(string: urlStr)!)
        UIApplication.shared.open(URL.init(string: urlStr)!, options: [:], completionHandler: nil)
    }
    
    /// 去App Store下载 <AppID: app的Id>
    public func nxm_toAppStoreUpdate(_ AppID: String) {
        let AppStoreURL = "https://apps.apple.com/cn/app/id\(AppID)?l=zh&ls=1&mt=8";
        let encodeUrl = AppStoreURL.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
        UIApplication.shared.open(URL.init(string: encodeUrl!)!, options: [:], completionHandler: nil)
    }
}

